package com.relatev.minecraft.TRMobAPI;

import org.bukkit.Bukkit;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.event.HandlerList;
import org.bukkit.plugin.java.JavaPlugin;

public class TRMobAPI extends JavaPlugin {

    private static TRMobAPI MainPlugin;
    private TRMobManager TRMobManager;
    private TRConfigManager TRConfigManager;
    private RunnableWorker RunnableWorker;

    @Override
    public void onEnable() {
        this.getLogger().info("是一套怪物系统API");
        this.getLogger().info("作者缇亚祢|群号664015345");
        this.getLogger().info("开始加载插件...");
        MainPlugin = this;
        Networker.init();
        TRMobManager = new TRMobManager();
        TRConfigManager = new TRConfigManager();
        RunnableWorker = new RunnableWorker();
        this.getLogger().info("加载成功结束！");
    }

    @Override
    public void onDisable() {
        TRMobManager.unloadAllMob();
        RunnableWorker.clearRunnables();
        HandlerList.unregisterAll(this);
        Bukkit.getScheduler().cancelTasks(MainPlugin);
        this.getLogger().info("已不再工作...");
    }

    @Override
    public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
        return CommandManager.onCommand(sender, command, label, args);
    }

    public static TRMobAPI getAPI() {
        return MainPlugin;
    }

    public TRMobManager getTRMobManager() {
        return TRMobManager;
    }

    public TRConfigManager getTRConfigManager() {
        return TRConfigManager;
    }

    public RunnableWorker getRunnableWorker() {
        return RunnableWorker;
    }
}
